home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DIALOG.ARJ / DIAG.PAS next >
Pascal/Delphi Source File  |  1991-03-19  |  2KB  |  87 lines

  1. { diag.pas - Dialog Library }
  2.  
  3. {$x+}
  4.  
  5. UNIT Diag;
  6.  
  7. INTERFACE
  8.  
  9. USES Crt, Objects, Views, App, Dialogs;
  10.  
  11. PROCEDURE AboutProgram(ProgramTitle: String);
  12. FUNCTION Yes(Prompt: String): Boolean;
  13. PROCEDURE ErrorMessage(ErrNumber: Integer; ErrMessage: String);
  14.  
  15. IMPLEMENTATION
  16.  
  17. {-Display "About Program" dialog box }
  18. PROCEDURE AboutProgram(ProgramTitle: String);
  19. VAR
  20.   AboutPtr: PDialog;
  21.   R: TRect;
  22. BEGIN
  23.   R.Assign(0, 0, 40, 11);
  24.   AboutPtr := New(PDialog, Init(R, 'About'));
  25.   IF (AboutPtr <> NIL) THEN WITH AboutPtr^ DO
  26.   BEGIN
  27.     Options := OPtions OR ofCentered;
  28.     R.Grow(-1, -1);
  29.     Insert(New(PStaticText, Init(R,
  30.     #13^C + ProgramTitle + #13 +
  31.     #13^C'Copyright (c) 1991'#13+
  32.     #13^C'by Tim Johnson'
  33.   )));
  34.   R.Assign(15, 8, 25, 10);
  35.   Insert(New(PButton, Init(R, 'O~K', cmOk, bfDefault)));
  36.   Desktop^.ExecView(AboutPtr);
  37.   Dispose(AboutPtr,Done)
  38.   END
  39.  END;
  40.  
  41.  {-Prompt user for Yes or No answer. Returns true for Yes }
  42.  FUNCTION Yes(Prompt: String): Boolean;
  43.  VAR
  44.    YNDiag: PDialog;
  45.    R: TRect;
  46.  BEGIN
  47.    R.Assign(0, 0, 60, 7);
  48.    YNDiag:= New(PDialog, Init(R, 'Please answer Yes or No'));
  49.    IF (YNDiag <> NIL) THEN WITH YNDiag^ DO
  50.    BEGIN
  51.      Options := Options OR ofCentered;
  52.      R.Grow(-1, -2);
  53.      Insert(New(PStaticText, Init(R, ^C+Prompt)));
  54.      R.Assign(35, 4, 43, 6);
  55.      Insert(New(PButton, Init(R, '~N~o', cmNo, bfNormal)));
  56.      R.Assign(17, 4, 26, 6);
  57.      Insert(New(PButton, Init(R, '~Y~es', cmYes, bfDefault)));
  58.      Yes := Desktop^.ExecView(YNDiag)= cmYes;
  59.      Dispose(YNDiag, Done)
  60.    END
  61.  END;
  62.  {-Display error message }
  63.  PROCEDURE ErrorMessage(ErrNumber: Integer; ErrMessage: String);
  64.  VAR
  65.    ErrDiag: PDialog;
  66.    R: Trect;
  67.    ENS: String[6];   {Error-Number string}
  68.  BEGIN
  69.    Str(ErrNumber, ENS);
  70.    R.Assign(0, 0, 60, 7);
  71.    ErrDiag:= New(PDialog, Init(R, 'Error #' + ENS));
  72.    IF (ErrDiag<> NIL) THEN WITH ErrDiag^ DO
  73.    BEGIN
  74.      Options := Options OR ofCentered;
  75.      R.Grow(1, -2);
  76.      Insert(New(PStaticText, Init(R, ^C+ErrMessage)));
  77.      R.Assign(20, 4, 40, 6);
  78.      Insert(New(PButton, Init(R, '~O~k', cmOK, bfNormal)));
  79.      Sound(400);
  80.      Delay(200);
  81.      NoSound;
  82.      Desktop^.ExecView(ErrDiag);
  83.      Dispose(ErrDiag, Done)
  84.      END
  85.   END;
  86. END.
  87.